﻿using System;
using System.Windows;

namespace CoffeeInventory
{
    /// <summary>
    /// Interaction logic for addSupplierWindow.xaml
    /// </summary>
    public partial class AddSupplierWindow
    {
        public AddSupplierWindow()
        {
            InitializeComponent();
        }

        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var name = _name.Text;
            var address = _address.Text;
            var phone = _phone.Text;
            if (!String.IsNullOrWhiteSpace(name) && !String.IsNullOrWhiteSpace(address) && !String.IsNullOrWhiteSpace(phone))
            {
                var supplier = new Supplier {Name = name, Address = address, Phone = phone};
                var context = new DBModelContainer();
                context.Suppliers.AddObject(supplier);
                context.SaveChanges();
                Close();
            }
        }
    }
}